home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / dopus / arexx / lhadir.dopus next >
Encoding:
Text File  |  1995-01-22  |  21.2 KB  |  885 lines

  1. /*
  2.   $VER: LhADir.dopus 1.9 (2.9.94)
  3.   Copyright © 1993-1994 by EAV Productions International
  4.   Placed in the public domain. No restrictions on distribution or usage.
  5.  
  6.   LhADir.dopus is an ARexx script for Directory Opus that allows you to show
  7.   the contents of LhA archives in a DOpus window and operate on the files and
  8.   directories inside an archive as if it is a normal directory.
  9.  
  10.   Possible arguments (not case sensitive) for LhADir.dopus:
  11.  
  12.    GETDIR, BROWSE, PARENT, ROOT, DELETE, COPY, MOVE, MAKEDIR, GETSIZES,
  13.    READ, ANSIREAD, HEXREAD, SHOW, PLAY, LOOPPLAY, PRINT, ICONINFO, RUN,
  14.    VERSION, UNDMS, MULTIVIEW, AMIGAGUIDE, VIEWTEK, RETINADISPLAY.
  15. */
  16.  
  17. signal on syntax    /* intercept syntax errors */
  18. options results        /* need results */
  19. options failat 21    /* external commands are allowed return code 20 */
  20. numeric digits 10    /* needed for convertdate routine */
  21. lf='a'x            /* ascii code for linefeed */
  22.  
  23. parse arg command portname . '"' selected '"'
  24. upper command
  25. if portname~=='' then
  26.    address(portname)
  27. else
  28.    portname=address()
  29. parse var portname '.' port  /* port number */
  30.  
  31. busy on            /* busy mouse pointer on */
  32. status 3        /* get active window */
  33. win=result
  34. status 9 win        /* get number of selected entries */
  35. entries=result
  36. checkabort        /* reset abort flag */
  37.  
  38. call checkconfig
  39. call checklhadir(win)
  40.  
  41. if selected~=='' then do
  42.    filetype=-1
  43.    entries=1
  44.    end
  45. else
  46.    if entries>0 then
  47.       call getnextone
  48.  
  49. topline=""
  50. listlha=0
  51. notmove=command~='MOVE'
  52. if pos('|'command'|','|GETDIR|BROWSE|PARENT|ROOT|DELETE|COPY|MOVE|MAKEDIR|GETSIZES|')>0 then
  53.    interpret 'call do'command
  54. else do
  55.    n=entries
  56.    async=pos('|'command'|','|READ|ANSIREAD|HEXREAD|')>0
  57.    internal=async|pos('|'command'|','|SHOW|PLAY|LOOPPLAY|PRINT|ICONINFO|RUN|')>0
  58.    if entries=0|async|(internal&~(lhadir&entries>0))|command='VERSION' then
  59.       n=1
  60.    thisfile=''
  61.  
  62.    do i=1 to n
  63.       checkabort
  64.       if result then
  65.      call quitit "Aborted..."
  66.  
  67.       if entries>0 then
  68.      if lhadir then do
  69.         if filetype>0 then
  70.            call quitit "Error, cannot view directories."
  71.         address command 'LhA e -q -x2 -Qo "'patch2(lhafile)'" T: "'patch(lhasubdir||selected)'"'
  72.         if rc>0 then
  73.            call quitit "Error while extracting file."
  74.         thisfile='"T:'selected'"'
  75.         end
  76.      else
  77.         if ~internal then
  78.            thisfile='"'selected'"'
  79.  
  80.       if internal then do
  81.      interpret '"'command '"'thisfile'""'
  82.      abort=result~=0
  83.      end
  84.       else do
  85.      if ~lhadir&entries>0 then
  86.         thisfile='"'winpath||selected'"'
  87.      query screenname
  88.      if result=0 then
  89.         screenname=portname  /* for compatibility */
  90.      else
  91.         screenname=result
  92.  
  93.      select  /* external commands */
  94.         when command='VERSION' then
  95.            call version
  96.         when command='UNDMS' then
  97.            call undms
  98.         when command='MULTIVIEW' then
  99.            address command 'MultiView' thisfile 'PUBSCREEN' screenname 'FONTNAME' fontname 'FONTSIZE' fontsize
  100.         when command='AMIGAGUIDE' then
  101.            address command 'AmigaGuide' thisfile 'PUBSCREEN' screenname
  102.         when command='VIEWTEK' then
  103.            address command 'Work:OtherTools/VT >NIL:' thisfile
  104.         when command='RETINADISPLAY' then
  105.            address command 'Work:Retina/RetinaTools/RetinaDisplay' thisfile
  106.         otherwise
  107.            call quitit "Error, LhADir.dopus does not support the command '"command"'."
  108.         end
  109.      abort=0
  110.      end
  111.  
  112.       busy on
  113.       if lhadir&entries>0 then do
  114.      if async then do
  115.         if ~show('l','rexxsupport.library') then
  116.            call addlib('rexxsupport.library',0,-30)  /* needed for delay() */
  117.         call delay(75)  /* wait a bit before deleting */
  118.         end
  119.      delete '"T:'selected'"'
  120.      busy on
  121.      end
  122.       if thisfile~=='' then do
  123.      selectfile '"'selected'" 0 1'  /* deselect item */
  124.      if topline=="" then
  125.         topline="OK"
  126.      end
  127.       if abort then
  128.      call quitit
  129.       if i<n then
  130.      call getnextone
  131.       end
  132.    end
  133.  
  134. call quitit topline  /* finished */
  135.  
  136.  
  137. dobrowse:
  138. dogetdir:
  139.  
  140.    if entries>0 then
  141.       if filetype>0 then  /* list a new dir */
  142.      if lhadir then
  143.         lhasubdir=lhasubdir||selected'/'
  144.      else
  145.         winpath=winpath||selected'/'
  146.       else do  /* list an archive file */
  147.      if pos('|'upper(right(selected,4)'|'),'|.LHA|.LZH|.RUN|')=0 then
  148.         call quitit "Error, LhADir.dopus can only list LhA archives."
  149.      if lhadir then do
  150.         request "This is an archive in an archive."lf"Extract it to 'T:' and then list it?"
  151.         uset=result
  152.         if uset then
  153.            destpath='T:'
  154.         else do
  155.            busy on
  156.            status 13 1-win  /* get window path */
  157.            destpath=result
  158.            if result=='' then
  159.           call quitit "Aborted..."
  160.            request "Use the current destination window"lf"'"destpath"' instead?"
  161.            if ~result then
  162.           call quitit "Aborted..."
  163.            end
  164.         busy on
  165.         toptext "Extracting from archive..."
  166.         address command 'LhA e -q -x2 -a -C0 -Qo "'patch2(lhafile)'" "'destpath'" "'patch(lhasubdir||selected)'"'
  167.         if rc>0 then
  168.            call quitit "Error while extracting from archive."
  169.         if ~uset&command='GETDIR' then
  170.            rescan 1-win
  171.         lhafile=destpath||selected
  172.         end
  173.      else
  174.         lhafile=winpath||selected
  175.      lhadir=1
  176.      lhasubdir=''
  177.      listlha=1
  178.      end
  179.    else  /* rescan current dir */
  180.       if lhadir then do
  181.      status 6 win  /* get number of entries */
  182.      listlha=result>0
  183.      end
  184.  
  185.    if command='BROWSE' then do
  186.       selectfile '"'selected'" 0 1'
  187.       call swapactive
  188.       end
  189.    if lhadir then do
  190.       call showlhadir
  191.       topline="OK"
  192.       end
  193.    else
  194.       status 13 win set '"'winpath'"'
  195.    return
  196.  
  197.  
  198. doparent:
  199.  
  200.    if lhadir&lhasubdir~=='' then do
  201.       cuthere=lastpos('/',lhasubdir,length(lhasubdir)-1)
  202.       lhasubdir=left(lhasubdir,cuthere)
  203.       call showlhadir
  204.       topline="OK"
  205.       end
  206.    else
  207.       parent
  208.    return
  209.  
  210.  
  211. doroot:
  212.  
  213.    if lhadir then do
  214.       cuthere=lastpos('/',lhafile,length(lhafile)-1)
  215.       if cuthere=0 then
  216.      cuthere=lastpos(':',lhafile)
  217.       status 13 win set '"'left(lhafile,cuthere)'"'
  218.       end
  219.    else
  220.       root
  221.    return
  222.  
  223.  
  224. dodelete:
  225.  
  226.    if lhadir then do
  227.       if entries=0 then
  228.      call quitit
  229.       if notmove then do
  230.      if ~askdelete then do
  231.         status 26 set "Delete"
  232.         request "Do you really wish to delete selected entries"lf"from archive?"
  233.         if ~result then
  234.            call quitit "Aborted..."
  235.         busy on
  236.         end
  237.      call getall
  238.      end
  239.       call open('actionfile','T:actionfile'port,'w')
  240.       do i=1 to entries
  241.      if type.i>0 then
  242.         wild='/#?'
  243.      else
  244.         wild=''
  245.      call writeln('actionfile','"'patch(lhasubdir||name.i)||wild'"')
  246.      removefile '"'name.i'" 0'
  247.      end
  248.       call close('actionfile')
  249.       toptext "Deleting from archive..."
  250.       address command 'LhA d -q -Qp -Qo "'patch2(lhafile)'" @T:actionfile'port
  251.       if rc>0 then do
  252.      topline="Error while deleting from archive."
  253.      listlha=1
  254.      call showlhadir
  255.      end
  256.       else do
  257.      topline="OK"
  258.      displaydir
  259.      end
  260.       delete 'T:actionfile'port
  261.       delete 'T:LhADir.list'port  /* archive contents has changed */
  262.       busy on
  263.       end
  264.    else do
  265.       if notmove then
  266.      restore
  267.       delete
  268.       end
  269.    return
  270.  
  271.  
  272. domove:
  273. docopy:
  274.  
  275.    if entries=0 then
  276.       call quitit
  277.    problem=0
  278.    source=winpath
  279.    s_lhadir=lhadir
  280.    s_lhafile=lhafile
  281.    s_lhasubdir=lhasubdir
  282.    call checklhadir(1-win)
  283.  
  284.    if s_lhadir then do
  285.       if winpath=='' then do
  286.      errortext="No destination directory selected!"
  287.      toptext errortext
  288.      notify errortext
  289.      call quitit
  290.      end
  291.       if lhadir then
  292.      winpath='T:LhADir'port'/'lhasubdir
  293.       call getall
  294.       call lhaextract
  295.       if lhadir then do
  296.      source=winpath
  297.      call lhaadd
  298.      end
  299.       else
  300.      if problem then
  301.         rescan 1-win
  302.      else do
  303.         do i=1 to entries
  304.            fileinfo '"'name.i'" /'
  305.            info.i=result
  306.            end
  307.         call swapactive
  308.         do i=1 to entries
  309.            parse var info.i name '/' size '/' '/' type '/' '/' days '/' seconds '/' comment '/' atts '/'
  310.            if type>0 then
  311.           size=0
  312.            addfile '"'name'"' size type seconds+days*86400 '"'comment'"' atts '0 0'
  313.            end
  314.         displaydir
  315.         call swapactive
  316.         end
  317.       end
  318.    else
  319.       if lhadir then do
  320.      call getall
  321.      call lhaadd
  322.      end
  323.       else do  /* normal copy/move */
  324.      restore
  325.      if notmove then
  326.         copy
  327.      else
  328.         move
  329.      end
  330.  
  331.    if (s_lhadir|lhadir)&~notmove&~problem then do
  332.       lhadir=s_lhadir
  333.       lhafile=s_lhafile
  334.       lhasubdir=s_lhasubdir
  335.       checkabort
  336.       if result then
  337.      call quitit "Aborted..."
  338.       call dodelete
  339.       end
  340.    return
  341.  
  342.  
  343. domakedir:
  344.  
  345.    getstring '"Enter directory name or archive name.lha"'
  346.    dirtomake=result
  347.    if rc|dirtomake=='' then
  348.       call quitit
  349.    now=date('i')*86400+time('s')
  350.    if lhadir then do  /* create empty dir in archive */
  351.       call createdirs dirtomake'/'
  352.       address command 'LhA a -q -e -r -Qo "'patch2(lhafile)'" T:LhADir'port'/' '"'patch(lhasubdir||dirtomake)'"'
  353.       if rc>0 then
  354.      topline="Error while adding to archive."
  355.       else do
  356.      topline="Directory created."
  357.      addfile '"'dirtomake'" 0 1' now '"" ----RWED 0 1'
  358.      end
  359.       delete 'T:LhADir'port
  360.       delete 'T:LhADir.list'port
  361.       busy on
  362.       end
  363.    else do
  364.       if upper(right(dirtomake,4))=='.LHA' then  /* create new archive */
  365.      if open('emptyarchive',winpath||dirtomake,'w') then do
  366.         call writech('emptyarchive','0'x)
  367.         call close('emptyarchive')
  368.         topline="Empty archive created."
  369.         addfile '"'dirtomake'" 1 -1' now '"" ----RWED 0 1'
  370.         end
  371.      else
  372.         topline="Error creating archive."
  373.       else do  /* normal makedir */
  374.      restore
  375.      makedir '"'dirtomake'"'
  376.      end
  377.       end
  378.    return
  379.  
  380.  
  381. dogetsizes:
  382.  
  383.    if lhadir then do
  384.       status 6 win  /* get total number of entries */
  385.       all=result
  386.       status 8 win  /* get number of dirs selected */
  387.       seldirs=result
  388.       n=1
  389.       do i=1 to all
  390.      getentry i
  391.      dirname.n=result
  392.      fileinfo '"'result'" /'
  393.      parse var result '/' filesize '/' '/' type '/' select '/'
  394.      if type>0&select&filesize=0 then
  395.         n=n+1
  396.      end
  397.       dirsize.=0
  398.       dirsecs.=0
  399.       ndirs=n-1
  400.       call readlist(0)
  401.       end
  402.    getsizes
  403.    return
  404.  
  405.  
  406. version:
  407.  
  408.    if entries=0 then
  409.       thisfile='DOpus:Rexx/LhADir.dopus'
  410.    toptext "Searching for version string..."
  411.    address command 'Version >T:Version.temp' thisfile 'FILE FULL'
  412.    call open('tempfile','T:Version.temp','r')
  413.    topline=readln('tempfile')
  414.    call close ('tempfile')
  415.    delete 'T:Version.temp'
  416.    return
  417.  
  418.  
  419. cleanupdms:
  420.    if exists("T:DIZ"portname) then
  421.      delete 'T:DIZ'portname
  422.    if exists("ENV:Device"portname) then
  423.      delete 'ENV:Device'portname
  424.   return
  425.  
  426. undms:
  427.    if entries=0|upper(right(selected,4))~=='.DMS' then
  428.       call quitit "No DMS file selected."
  429.  
  430.  
  431.    /* Modified by Allan & Tommy */
  432.    address command 'DOpus:DizExtract/DMSdiz >NIL: x T:DIZ'portname thisfile
  433.    if ~exists("T:DIZ"portname) then
  434.       address command 'SelectDevice >ENV:Device'portname' "Unpack to Device" "No File_ID.Diz File" CX CY LC=0 HC=79 SF=2 BPT=11 PS=' portname
  435.    else
  436.       address command 'SelectDevice >ENV:Device'portname' "Unpack to Device" T:DIZ'portname' FILE CX CY LC=0 HC=79 SF=2 BPT=11 PS=' portname
  437.    if RC>0 then do
  438.       call cleanupdms
  439.       call quitit "No device selected..."
  440.       end
  441.  
  442.    call open('temp','ENV:Device'portname,'r')
  443.    drive=readln('temp')
  444.    close('temp')
  445.    call cleanupdms
  446.  
  447. /*
  448.    drive.1='DF0:'
  449.    /* drive.0='RAD:' */
  450.    drive.0='FF0:'
  451.    status 26 set drive.1
  452.    status 27 set drive.0
  453.    toptext thisfile
  454.    request "Please insert disk and select"lf"destination drive for DMS file"
  455.    dest=result
  456.    busy on
  457.    checkabort
  458.    if result then
  459.       call quitit "Aborted..."
  460. */
  461.  
  462.    /* address command 'Run >NIL: <NIL: DMS <NIL: >PIPE:dmsout WRITE' thisfile 'TO ' drive.dest ' NOTEXT' */
  463.    address command 'Run >NIL: <NIL: DMS <NIL: >PIPE:dmsout WRITE' thisfile 'TO ' drive 'NOTEXT'
  464.    address command 'Status >T:ProcessNo COMMAND=DMS'
  465.    call open('temp','T:ProcessNo','r')
  466.    process=readln('temp')
  467.    close('temp')
  468.    delete 'T:ProcessNo'
  469.    busy on
  470.  
  471.    nomess=1
  472.    errors=''
  473.    buffer=''
  474.    call open('dmsout','PIPE:dmsout','r')
  475.    do until eof('dmsout')
  476.       buffer=buffer||readch('dmsout',25)
  477.       here=verify(buffer,'a0d'x,'m')
  478.       if here>0 then do
  479.      line=left(buffer,here-1)
  480.      if nomess&left(line,7)=='No Disk' then do
  481.         /* toptext "Insert disk in" drive.dest */
  482.         toptext "Insert disk in" drive
  483.         nomess=0
  484.         end
  485.      parse var line ' ' line
  486.      buffer=substr(buffer,here+1)
  487.      if pos('ERROR',upper(line))>0 then do
  488.         errors=errors||lf||line
  489.         beep
  490.         busy on
  491.         end
  492.      if left(line,9)=='unPacking' then do
  493.         toptext selected '-' line
  494.         checkabort
  495.         if result then do
  496.            address command 'Break' process 'C'
  497.            topline="Aborted..."
  498.            end
  499.         end
  500.      end
  501.       end
  502.    call close('dmsout')
  503.    if errors~=='' then do
  504.       toptext thisfile
  505.       notify "Error Report"||lf||errors
  506.       end
  507.    return
  508.  
  509.  
  510. checklhadir:
  511.  
  512.    arg checkwin
  513.    status 13 checkwin  /* get window path */
  514.    winpath=result
  515.    test=upper(winpath)
  516.    cuthere=pos('.LHA/',test)
  517.    if cuthere=0 then
  518.       cuthere=pos('.LZH/',test)
  519.    if cuthere=0 then
  520.       cuthere=pos('.RUN/',test)
  521.    lhadir=cuthere>0
  522.    if lhadir then do
  523.       lhafile=left(winpath,cuthere+3)
  524.       lhasubdir=substr(winpath,cuthere+5)
  525.       end
  526.    return
  527.  
  528.  
  529. lhaextract:
  530.  
  531.    status 8 win  /* get number of dirs selected */
  532.    anydirs=result>0
  533.    mustmove=anydirs&s_lhasubdir~==''
  534.    if mustmove then
  535.       destpath=winpath'LhADir'port'/'
  536.    else
  537.       destpath=winpath
  538.  
  539.    call open('actionfile','T:actionfile'port,'w')
  540.    do i=1 to entries
  541.       if type.i>0 then
  542.      wild='/#?'
  543.       else
  544.      wild=''
  545.       call writeln('actionfile','"'patch(s_lhasubdir||name.i)||wild'"')
  546.       end
  547.    call close('actionfile')
  548.  
  549.    if anydirs then
  550.       lhacmd='x'
  551.    else
  552.       lhacmd='e -x2'
  553.    toptext "Extracting from archive..."
  554.    address command 'LhA' lhacmd '-q -a -C0 -Qo "'patch2(s_lhafile)'" "'destpath'" @T:actionfile'port
  555.    problem=rc>0
  556.    if problem then
  557.       topline="Error while extracting from archive."
  558.    else do
  559.       topline="OK"
  560.       if notmove then
  561.      none
  562.       end
  563.  
  564.    if mustmove then do
  565.       do i=1 to entries
  566.      move '"'winpath'LhADir'port'/'s_lhasubdir||name.i'" "'winpath'"'
  567.      end
  568.       delete '"'winpath'LhADir'port'"'
  569.       end
  570.    delete 'T:actionfile'port
  571.    busy on
  572.    return
  573.  
  574.  
  575. lhaadd:
  576.  
  577.    mustcopy=upper(right(source,length(lhasubdir)))~==upper(lhasubdir)
  578.    if mustcopy then do  /* all files must be copied to T: before they can be added */
  579.       homedir='T:LhADir'port'/'
  580.       call createdirs
  581.       end
  582.    else
  583.       homedir=left(source,length(source)-length(lhasubdir))
  584.    call open('actionfile','T:actionfile'port,'w')
  585.    call writeln('actionfile','"'patch(homedir)'"')
  586.  
  587.    if s_lhadir then
  588.       call writeln('actionfile','#?')
  589.    else do
  590.       do i=1 to entries
  591.      call writeln('actionfile','"'patch(lhasubdir||name.i)'"')
  592.      if mustcopy then do
  593.         copy '"'source||name.i'" "T:LhADir'port'/'lhasubdir'"'
  594.         busy on
  595.         end
  596.      end
  597.       end
  598.    call close('actionfile')
  599.  
  600.    if pos('.LZH/',test)>0 then
  601.       method='-0'
  602.    else
  603.       method=''
  604.    toptext "Adding to archive..."
  605.    address command 'LhA r' method '-q -e -r -Qo "'patch2(lhafile)'" @T:actionfile'port
  606.    problem=rc>0
  607.    if problem then
  608.       topline="Error while adding to archive."
  609.    else do
  610.       topline="OK"
  611.       if notmove then
  612.      none
  613.       end
  614.    delete 'T:actionfile'port
  615.    if mustcopy|s_lhadir then
  616.       delete 'T:LhADir'port
  617.    busy on
  618.    call swapactive
  619.    listlha=1
  620.    call showlhadir
  621.    call swapactive
  622.    return
  623.  
  624.  
  625. lhalist:
  626.  
  627.    address command 'LhA >T:LhADir.list'port 'vv -N -Qw -Qo "'lhafile'"'
  628.    if rc>0 then do
  629.       setwintitle '"<Directory not available>"'
  630.       call quitit "Error while listing archive."
  631.       end
  632.    return
  633.  
  634.  
  635. getnextone:
  636.  
  637.    getnextselected
  638.    selected=result
  639.    if follow then
  640.       scrolltoshow '"'selected'"'
  641.    fileinfo '"'selected'" /'
  642.    parse var result '/' '/' '/' filetype '/'
  643.    return
  644.  
  645.  
  646. getall:
  647.  
  648.    status 6 win  /* get total number of entries */
  649.    all=result
  650.    n=1
  651.    do i=1 to all
  652.       getentry i
  653.       name.n=result
  654.       fileinfo '"'result'" /'
  655.       parse var result '/' '/' '/' type.n '/' select '/'
  656.       if select then
  657.      n=n+1
  658.       if n>entries then
  659.      leave
  660.       end
  661.    return
  662.  
  663.  
  664. createdirs:
  665.  
  666.    parse arg subdir
  667.    dirstocreate='T:LhADir'port'/'lhasubdir||subdir
  668.    here=0
  669.    do forever
  670.       here=pos('/',dirstocreate,here+1)
  671.       if here=0 then
  672.      leave
  673.       makedir '"'left(dirstocreate,here-1)'"'
  674.       end
  675.    busy on
  676.    return
  677.  
  678.  
  679. swapactive:
  680.  
  681.    otherwindow
  682.    win=1-win
  683.    return
  684.  
  685.  
  686. showlhadir:
  687.  
  688.    status 13 win set '"'lhafile'/'lhasubdir'"'
  689.    toptext "Listing archive..."  /* toptext obscures error message */
  690.    setwintitle '"LhADir listed archive"'
  691.    now=date('i')*86400+time('s')
  692.    ndirs=0
  693.    call readlist(1)
  694.    return
  695.  
  696.  
  697. readlist:
  698.  
  699.    arg show  /* showdir or getsizes? */
  700.    if listlha|~exists('T:LhADir.list'port) then
  701.       call lhalist
  702.    call open('tempfile','T:LhADir.list'port,'r')
  703.    nextline=readln('tempfile')
  704.    parse var nextline 21 whicharc "':"
  705.    if upper(whicharc)~==upper(lhafile) then do  /* it's another archive's list */
  706.       call close('tempfile')
  707.       call lhalist
  708.       call open('tempfile','T:LhADir.list'port,'r')
  709.       call readln('tempfile')
  710.       end
  711.    do 2
  712.       call readln('tempfile')  /* waste these 2 lines */
  713.       end
  714.  
  715.    compstr=upper(lhasubdir)
  716.    complen=length(compstr)
  717.    nextline=readln('tempfile')
  718.  
  719.    do forever
  720.  
  721.       name=nextline
  722.       infoline=readln('tempfile')
  723.       do while pos('% ',infoline)<22
  724.      name=infoline
  725.      infoline=readln('tempfile')
  726.      end
  727.       if name=='-------- ------- ----- --------- --------' then
  728.      leave
  729.       nextline=readln('tempfile')
  730.       if left(nextline,1)==':' then do
  731.      parse var nextline 3 comment
  732.      nextline=readln('tempfile')
  733.      end
  734.       else
  735.      comment=''
  736.  
  737.       if upper(left(name,complen))==compstr then do
  738.      name=substr(name,complen+1)
  739.      if name~==''&pos('"',name)=0 then do
  740.         if pos('/',name)>0 then do  /* it's a dir */
  741.            parse var name dirname '/'
  742.            olddir=0
  743.            do i=ndirs to 1 by -1
  744.           if upper(dirname)==upper(dirname.i) then do
  745.              olddir=1
  746.              if ~show then do
  747.             toptext winpath||name
  748.             parse var infoline size . '% ' datestamp +18
  749.             dirsize.i=dirsize.i+size
  750.             seconds=convertdate(datestamp)
  751.             if seconds>dirsecs.i then
  752.                dirsecs.i=seconds
  753.             end
  754.              leave
  755.              end
  756.           end
  757.            if show&~olddir then do  /* a new dir */
  758.           ndirs=ndirs+1
  759.           dirname.ndirs=dirname
  760.           addfile '"'dirname'" 0 1' now '"" ----RWED 0 0'
  761.           end
  762.            end
  763.         else  /* it's a file */
  764.            if show then do
  765.           parse var infoline size . '% ' datestamp +18 +1 atts .
  766.           seconds=convertdate(datestamp)
  767.           addfile '"'name'"' size '-1' seconds '"'comment'"' atts '0 0'
  768.           end
  769.         end
  770.      end
  771.       end
  772.    call close('tempfile')
  773.    if ~show then
  774.       do i=1 to ndirs
  775.      addfile '"'dirname.i'"' dirsize.i '1' dirsecs.i '"" ----RWED 0 0'
  776.      selectfile '"'dirname.i'"'
  777.      end
  778.    displaydir
  779.    return
  780.  
  781.  
  782. convertdate:  /* convert a file's date stamp to seconds past 01-Jan-78 */
  783.  
  784.    parse arg day '-' month '-' year ' ' hours ':' minutes ':' seconds
  785.    century=19+(year<78)
  786.    month=pos(month,'  JanFebMarAprMayJunJulAugSepOctNovDec')/3
  787.    month=right(month,2,'0')
  788.    return seconds+minutes*60+hours*3600+date('i',century||year||month||day,'s')*86400
  789.  
  790.  
  791. patch:  /* patch file names containing pattern matching tokens */
  792.  
  793.    parse arg patched
  794.    pos=1
  795.    do forever
  796.       here=verify(substr(patched,pos),"*#?|%()[]~'",'m')
  797.       if here=0 then
  798.      leave
  799.       pos=pos+here+1
  800.       patched=insert("'",patched,pos-3)
  801.       end
  802.    do forever
  803.       here=verify(substr(patched,pos),'@','m')
  804.       if here=0 then
  805.      leave
  806.       pos=pos+here+1
  807.       patched=insert("*",patched,pos-3)
  808.       end
  809.    return patched
  810.  
  811.  
  812. patch2:  /* for LhA file names */
  813.  
  814.    parse arg patched
  815.    pos=1
  816.    do forever
  817.       here=verify(substr(patched,pos),'*#?|%()[]~','m')
  818.       if here=0 then
  819.      leave
  820.       pos=pos+here+1
  821.       patched=insert("'",patched,pos-3)
  822.       end
  823.    do forever
  824.       here=verify(substr(patched,pos),"@'",'m')
  825.       if here=0 then
  826.      leave
  827.       pos=pos+here+1
  828.       patched=insert("*",patched,pos-3)
  829.       end
  830.    return patched
  831.  
  832.  
  833. syntax:
  834.  
  835.    call quitit "Syntax Error" rc"," errortext(rc) "in line" sigl"."
  836.  
  837.  
  838. checkconfig:
  839.  
  840.    status 26
  841.    okaystring=result
  842.    status 27
  843.    cancelstring=result
  844.  
  845.    query dirflags
  846.    olddirflags=result
  847.    if olddirflags<0 then  /* bug in DOpus? */
  848.       olddirflags=256+olddirflags
  849.    if bittst(d2c(olddirflags),5) then do
  850.       request "The config setting 'Re-read changed buffers'"lf"must be switched off. Shall I do this for you?"
  851.       if ~result then do
  852.      remember  /* something to restore */
  853.      call quitit "Error, config setting 'Re-read changed buffers' must be switched off."
  854.      end
  855.       modify dirflags olddirflags-32
  856.       end
  857.  
  858.    remember                /* remember user settings */
  859.    busy on
  860.    query updateflags
  861.    follow=bittst(d2c(result),1)        /* scroll window to follow operations? */
  862.    modify updateflags 0            /* no progress indicator */
  863.    query deleteflags
  864.    askdelete=bittst(d2c(result),0)    /* ask before deleting? */
  865.    modify deleteflags 8            /* don't ask when deleting internal */
  866.    modify replaceflags 1        /* don't ask when replacing internal */
  867.    modify iconflags 0            /* no icons please */
  868.    query font 2                /* text viewer font */
  869.    parse var result fontname '.font/' fontsize
  870.    return
  871.  
  872.  
  873. quitit:
  874.  
  875.    parse arg topline
  876.    status 26 set okaystring        /* restore okay and */
  877.    status 27 set cancelstring        /* cancel strings */
  878.    restore                   /* restore user settings */
  879.    if topline~=="" then
  880.       toptext topline            /* display final message */
  881.    if pos("Error",topline)>0 then
  882.       beep                /* an error occurred */
  883.    busy off                /* busy mouse pointer off */
  884.    exit                    /* stop script here */
  885.